<?php
namespace app\admins\controller;

use \think\Controller;
use \think\Db;

class Adminc extends Controller
{
    public function admin_competence()
    {

    	return $this->fetch();
    }
     public function administrator()
    {
    	$users=Db::name('madmin')->select();
    	$this->assign('users',$users);
    	return $this->fetch();
    }
    public function admin_info()
    {
    	
    	return $this->fetch();
    }
    public function add(){
    	$name=input('param.user-name');
    	$num=Db::name('madmin')->where("m_name='$name'")->count();
    	if($num>0){
    		$this->error("该管理员已存在");
    	}
    	else{
    		if(request()->isPost()){
    		$data=['m_name'=>input('param.user-name'),
    				'm_password'=>md5('param.userpassword'),
    				'm_address'=>input('param.user-address'),
    				'm_phone'=>input('param.user-tel'),
    				'm_starttime'=>date('Y-m-d H:i:s')];
    		$res=Db::name('madmin')->insert($data);
    		if($res)
		{
			$this->success("添加用户成功");
		}
		else
		{
			$this->error("添加用户失败");
		}
    	}
    }
    }

    public function delete($id){
		
		
		if(Db::name("madmin")->delete($id))
		{
			echo Db::name("videos")->getLastSql();exit;
			$this->success('删除成功');
		}else $this->error('删除失败');
}
}